package svc

import (
	"cloud-disk/core/internal/config"
	"cloud-disk/core/internal/middleware"
	"cloud-disk/core/models"
	"github.com/go-redis/redis/v8"
	"github.com/minio/minio-go/v7"
	"github.com/zeromicro/go-zero/rest"
	"gorm.io/gorm"
)

type ServiceContext struct {
	Config      config.Config
	DbConn      *gorm.DB
	RedisClient *redis.Client
	MinioClient *minio.Client
	Auth        rest.Middleware
	Cors        rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:      c,
		DbConn:      models.InitDB(c),
		RedisClient: models.InitRedis(c),
		MinioClient: models.InitMinio(c),
		Auth:        middleware.NewAuthMiddleware().Handle,
		Cors:        middleware.NewCorsMiddleware().Handle,
	}
}
